package FactoryPattern;

// 披萨接口
interface Pizza {
    void prepare();
    void bake();
    void cut();
    void box();
}

// 纽约披萨类
class NewYorkPizza implements Pizza {
    public void prepare() {
        System.out.println("Preparing New York Style Pizza");
    }

    public void bake() {
        System.out.println("Baking New York Style Pizza");
    }

    public void cut() {
        System.out.println("Cutting New York Style Pizza");
    }

    public void box() {
        System.out.println("Boxing New York Style Pizza");
    }
}

// 披萨工厂类
class PizzaFactory {
    public Pizza createPizza(String type) {
        if (type.equals("New York")) {
            return new NewYorkPizza();
        } else {
            throw new IllegalArgumentException("Unknown pizza type: " + type);
        }
    }
}

public class PizzaStore {
    public static void main(String[] args) {
        PizzaFactory pizzaFactory = new PizzaFactory();
        Pizza pizza = pizzaFactory.createPizza("New York");

        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
    }
}
